package com.xjm.i1.core.struct.node.write;

import cn.hutool.core.util.NumberUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 导出Excel数据中灰度偏差的数据结构
 **/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ExcelGray extends AbstractExcelCollection{

    private double value25L;

    private double value25A;

    private double value25B;

    private double value50L;

    private double value50A;

    private double value50B;

    private double value75L;

    private double value75A;

    private double value75B;

    private double value100L;

    private double value100A;

    private double value100B;

    private double formula25AB;

    private double formula50AB;

    private double formula75AB;

    private double formula100AB;

    private double formulaABAVG;

    public ExcelGray(String deviceId, String env, String pageId) {
        super(deviceId, env, pageId, null);
    }

    public double calculate25AB() {
        return NumberUtil.round(
                Math.sqrt(Math.pow(this.value25A, 2.0D) + Math.pow(this.value25B, 2.0D))
                , 2).doubleValue();
    }

    public double calculate50AB() {
        return NumberUtil.round(
                Math.sqrt(Math.pow(this.value50A, 2.0D) + Math.pow(this.value50B, 2.0D))
                ,2).doubleValue();
    }

    public double calculate75AB() {
        return NumberUtil.round(
                Math.sqrt(Math.pow(this.value75A, 2.0D) + Math.pow(this.value75B, 2.0D))
                ,2).doubleValue();
    }

    public double calculate100AB() {
        return NumberUtil.round(
                Math.sqrt(Math.pow(this.value100A, 2.0D) + Math.pow(this.value100B, 2.0D))
                ,2).doubleValue();
    }

    public double calculateABAVG() {
        return NumberUtil.round(
                (this.calculate25AB() + this.calculate50AB() + this.calculate75AB() + this.calculate100AB()/4.0D)
                ,2).doubleValue();
    }
}
